<template>
  <div>
    <h3>学习使用element</h3>
  
    <el-form  :model="form" :rules="rules">
      <el-form-item prop="uname">
        <el-input v-model="form.uname"> </el-input>
      </el-form-item>
      
    </el-form>
   
    <!-- <el-form :model="form" :rules="rules">
     
      <el-form-item label="活动名称" prop="name">
        
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form> -->
  </div>
</template>

<script>
export default {
  name: 'useEle',
  data () {
    return {
      form: {
        uname: '',
        pwd: ''
      },
      rules: {
        uname: [
            { required: true, message: '请输入用户名', trigger: 'blur' },
            { min: 3, max: 11, message: '长度在 3 到 5 个字符', trigger: 'blur' },
            {validator:(rule,value,callback)=>{
                const reg = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/
                const bool =  reg.test(value)
                bool ? callback() : callback(new Error('手机号不合法'))
            },trigger:'blur'}
        ]
      }
    }
  }
//  data () {
//         return {
//             form: {
//               name: ''  
//             },
//             rules: {
//                 name: [
//                     { required: true, message: '请输入活动名称', trigger: 'blur' },
//                     { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
//                 ]
//         }
//     }
// }
}
</script>

<style></style>
